#ifndef _QUEUE_H_
#define _QUEUE_H_

/**********************************
write by zhangliang <liangzhws@foxmail.com>
**********************************/

#include "list.h"

/*********************************
queue model:
	    ------
queue head | head |
            ------\
                   \
                    >  ------
                      | queue  ...  |
                       ------
*********************************/
#ifdef _DLIST_T
#define _QUEUE_T
typedef dlist_t queue_t;

#ifdef _DLIST_S
#define _QUEUE_S
#define queue_s dlist_s

#define init_head_queue_t(head) init_head_dlist_t(head)

/**
  @name: queue_is_empty
  @function: judge the queue is empty or not
  @param: #const list_t * head# queue head
  @return: #bool# true is represent for empty queue, false is represent for not empty queue
  @algorithm complexity: O(1)
*/
bool queue_is_empty(const queue_t * head);

/**
  @name: queue_push
  @function: push one entry into last of the queue use the rule of queue
  @param: #queue_t * head# the head of the queue
  @param: #queue_t * entry# the entry of want to be pushed
  @return: #void#
  @algorithm complexity: O(1)
*/
void queue_push(queue_t * head, queue_t * entry);

/**
  @name: queue_pop
  @function: get the first entry from the queue and delete this one
  @param: #queue_t * head# the head of the queue
  @return #queue_t *# the first entry for the queue or null represent noting can be get
  @algorithm complexity: O(1)
*/
queue_t * queue_pop(queue_t * head);

/**
  @name: queue_empty
  @function: empty the queue
  @param: #queue_t * head# the head of the queue
  @return #void#
  @algorithm complexity: O(1)
*/
void queue_empty(queue_t * head);

/**
  @name: queue_is_exist
  @function: judge the entry in queue head or not
  @param: #const queue_t * head# queue head
  @param: #const queue_t * entry# queue unit
  @return: #bool# true is exist and false isn't exist
  @algorithm complexity: O(n)
*/
bool queue_is_exist(const queue_t * head, const queue_t * entry);
#endif /* _DLIST_S */ 

#endif /* _DLIST_T */


#endif /* _QUEUE_H_ */
